package com.geektime.hello.controller;

import com.geektime.hello.model.Coupon;
import com.geektime.hello.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/coupon")
public class CouponController {

    @Autowired
    private CouponService couponService;

    @GetMapping
    @RequestMapping("/list")
    public List<Coupon> list() {
        return couponService.findCouponList();
    }

    @GetMapping("/list2")
    public List<Coupon> list2() {
        return couponService.findCouponListByHql();
    }

    @GetMapping
    @RequestMapping("/list4jdbc")
    public List<Map<String, Object>> list4jdbc() {
        return couponService.findCouponList4Jdbc();
    }

}
